package com.example.finalwork06.Service.Impl;

import com.example.finalwork06.Entity.NewShares;
import com.example.finalwork06.Entity.PageBean;
import com.example.finalwork06.Mapper.NewSharesMapper;
import com.example.finalwork06.Service.NewSharesService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewSharesServiceImpl implements NewSharesService {
    @Autowired
    private NewSharesMapper newSharesMapper;
    @Override
    public PageBean page(Integer page, Integer pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);
        //2.查询
        List<NewShares> List=newSharesMapper.list();
        Page<NewShares> p=(Page<NewShares>) List;
        //3.封装
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }
}
